package de.hypoport.einarbeitung.scrumspirit.persistence.genericdao.jpa2;

import java.util.Collection;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityNotFoundException;
import javax.persistence.LockModeType;
import javax.persistence.Query;

/**
 * Adapter class that implements all methods with no op/return null/return false
 * operations, mainly useful for test stubs base class.
 * 
 * @author Jeff Jensen
 */
public class Jpa2DaoAdapter<K, E> implements Jpa2Dao<K, E> {
    @Override
    public void clear() {
    }

    @Override
    public boolean contains(E entity) {
        return false;
    }

    @Override
    public List<E> findAll() {
        return null;
    }

    @Override
    public List<E> findAll(int startPosition, int maxResult) {
        return null;
    }

    @Override
    public E findById(K id) {
        return null;
    }

    @Override
    public void flush() {
    }

    @Override
    public E merge(E entity) {
        return null;
    }

    @Override
    public void persist(Collection<E> entities) {
    }

    @Override
    public void store(E entity) {
    }

    @Override
    public void refresh(E entity) {
    }

    @Override
    public void remove(E entity) {
    }

    @Override
    public void removeById(K id) {
    }

    @Override
    public void removeById(K id, boolean exceptionIfNotFound) {
    }

    @Override
    public E findById(K id, LockModeType lockMode, boolean exceptionIfNotFound) {
        if (exceptionIfNotFound) {
            final String msg = "Override this method to avoid this exception.";
            throw new EntityNotFoundException(msg);
        }
        return null;
    }

    @Override
    public EntityManager getEntityManager() {
        return null;
    }

    @Override
    public E runQueryWithSingleResult(Query q, LockModeType lockMode,
            boolean exceptionIfNotFound) {
        if (exceptionIfNotFound) {
            final String msg = "Override this method to avoid this exception.";
            throw new EntityNotFoundException(msg);
        }
        return null;
    }

    @Override
    public E runQueryWithSingleResult(Query q) {
        return null;
    }

    @Override
    public void setEntityManager(EntityManager entityManager) {
    }

    @Override
    public Long countAll() {
        return null;
    }

    @Override
    public Long countAll(String where) {
        return null;
    }

    @Override
    public Long countAll(String where, String pathExpression) {
        return null;
    }

	@Override
	public void setNeedTransaction(boolean needTransaction) {

	}

	@Override
	public boolean isNeedTransaction() {
		return false;
	}
}
